package edums.student.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import edums.employee.dto.StudentDTO;
import edums.student.dto.GuestBookDTO;

public class GuestBookDAOImpl implements GuestBookDAO {
	private SqlMapClientTemplate client;
	public GuestBookDAOImpl(SqlMapClientTemplate client){
		this.client = client;
	}

	@Override
	public void insertGuestBook(GuestBookDTO gdto) throws SQLException{
		client.insert("guestBook.insertGuestBook", gdto);
	}

	@Override
	public void removeGuestBook(Map guestBookInfo) throws SQLException {
		client.delete("guestBook.deleteGuestBook", guestBookInfo);
	}

	@Override
	public int selectGuestBookNo(String studentId) throws SQLException {
		return (Integer) client.queryForObject("guestBook.selectGuestBookNo", studentId);
	}

	@Override
	public GuestBookDTO selectGuestBookById(Map guestBookInfo)
			throws SQLException {
		return (GuestBookDTO) client.queryForObject("guestBook.selectGuestBookById", guestBookInfo);
	}

	@Override
	public GuestBookDTO selectGuestBookForModifyForm(Map guestBookInfo)
			throws SQLException {
		return (GuestBookDTO) client.queryForObject("guestBook.selectGuestBookForModifyForm", guestBookInfo);
	}

	@Override
	public void updateGuestBook(GuestBookDTO gdto) throws SQLException {
		client.update("guestBook.updateGuestBook", gdto);
	}

	@Override
	public List selectAllGuestBook(Map guestBookInfo) throws SQLException {
		return client.queryForList("guestBook.selectAllGuestBook", guestBookInfo);
	}

	@Override
	public int selectGuestBookTotalContent(Map guestBookInfo)
			throws SQLException {
		return (Integer) client.queryForObject("guestBook.selectGuestBookTotalContent", guestBookInfo);
	}

	@Override
	public List selectGuestBookReplyCount(Map guestBookInfo) throws SQLException {
		return client.queryForList("guestBook.selectGuestBookReplyCount", guestBookInfo);
	}

	@Override
	public List selectGuestBookReply(Map guestBookInfo) throws SQLException {
		return client.queryForList("guestBook.selectGuestBookReply", guestBookInfo);
	}

	@Override
	public int selectReplyRestep(GuestBookDTO gdto) throws SQLException {
		return (Integer) client.queryForObject("guestBook.selectReplyRestep", gdto);
	}

	@Override
	public void deleteReply(Map guestBookInfo) throws SQLException {
		client.delete("guestBook.deleteReply", guestBookInfo);
	}

	@Override
	public void updateReply(GuestBookDTO gdto) throws SQLException {
		client.update("guestBook.updateReply", gdto);
	}

	@Override
	public StudentDTO selectStudentInfo(String studentId) throws SQLException {
		return (StudentDTO) client.queryForObject("guestBook.selectStudentInfo", studentId);
	}
	
}
